home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / t3_1 / doc.lha / documentation / manual / text.mss < prev    next >
Text File  |  1987-06-30  |  18KB  |  541 lines

  1. @part[TEXT, Root "TMAN.MSS"]    @Comment{-*-System:TMAN-*-}
  2. @chap[Characters and strings]
  3.  
  4.  
  5. @tau[] has a special data type for representing @i[characters].
  6. Characters are objects which may be stored in strings and communicated
  7. between the @tau[] system and external media such as files and
  8. terminals.  Most characters represent printed graphics
  9. such as letters, digits, and punctuation.
  10.  
  11. @label[character syntax]        @Comment{ref: syntax chapter}
  12. The external syntax @tc[#\]@i[x] is used for characters.
  13. @i[x] may either be a single character or the @qu[name] of a character.
  14. Valid character names include @tc[SPACE], @tc[TAB], @tc[FORM],
  15. and @tc[NEWLINE].  For example:
  16. @Begin[Display]
  17. @Tabdivide(5)
  18. @tc[#\b]       @\The alphabetic character lower-case @i[b]
  19. @tc[#\7]       @\The digit 7
  20. @tc[#\;]       @\The special character @i[semicolon]
  21. @tc[#\tab]     @\The tab character
  22. @tc[#\NEWLINE] @\The new-line character
  23. @End[Display]
  24.  
  25. Some graphic characters are also readable by name:
  26.   @begin[ProgramExample]
  27. #\LEFT-PAREN      @ce[]   #\(
  28. #\RIGHT-PAREN     @ce[]   #\)
  29. #\LEFT-BRACKET    @ce[]   #\[
  30. #\RIGHT-BRACKET   @ce[]   #\]
  31. #\LEFT-BRACE      @ce[]   #\{
  32. #\RIGHT-BRACE     @ce[]   #\}
  33. #\BACKSLASH       @ce[]   #\\
  34. #\QUOTE           @ce[]   #\'
  35. #\BACKQUOTE       @ce[]   #\`
  36. #\DOUBLEQUOTE     @ce[]   #\"
  37. #\COMMA           @ce[]   #\,
  38. #\SEMICOLON       @ce[]   #\;
  39.   @end[ProgramExample]
  40.  
  41. The syntax @tc<#[Char @i[n]]> may also be used for characters,
  42. where @i[n] is the ASCII code for the character (see section
  43. @ref[CHAR->ASCII]).  This is not preferred, however, since it is
  44. less readable and less abstract than the @tc[#\] syntax.
  45.  
  46.   @begin[ProgramExample]
  47. #[Char 65]  @ce[]  #\A
  48.   @end[ProgramExample]
  49.  
  50. Unlike numbers, characters @i[are] uniquely instantiated.
  51. There is only one object which represents a given graphic or other character.
  52.   @begin[ProgramExample]
  53. (EQ? #\x #\x)  @yl[]  @r[true]
  54.   @end[ProgramExample]
  55.  
  56. Characters and strings are self-evaluating.  There is no need to quote them
  57. to use them as constants in programs.
  58.  
  59. Strings are sequences of characters.  @dc{ Elaborate? }
  60. Strings actually consist of two
  61. distinct components, a @i[header] and a @i[text], which may be
  62. manipulated independently of each other.  If one doesn't use the
  63. routines in section @ref[string header section]@dc{ ???}, one need not
  64. even be aware of this fact, and can treat strings as if they are similar
  65. to lists of characters.
  66.  
  67. Strings are notated simply by enclosing the actual sequence of characters
  68. within double quote characters.  For example,
  69.   @begin[ProgramExample]
  70. "Horse"
  71.   @end[ProgramExample]
  72. notates a five-character string consisting of the characters
  73. @tc[#\H], @tc[#\o], @tc[#\r], @tc[#\s], and @tc[#\e].
  74. The escape character (also known as backslash: @tc[\]) may be used
  75. to include a double-quote or a backslash within a string:
  76.   @begin[ProgramExample]
  77. "The \"second\" word in this string is enclosed in double-quotes."
  78. "\\ This string begins with one backslash."
  79.   @end[ProgramExample]
  80. There is no standard way to notate a string which contains non-graphic
  81. characters (e.g. control characters).
  82.  
  83. Strings are not uniquely instantiated; e.g.
  84.   @begin[ProgramExample]
  85. (EQ? "Eland" "Eland")
  86.   @end[ProgramExample]
  87. may or may not yield true, depending on the implementation.
  88.  
  89. @section[Predicates]
  90.  
  91. @info[NOTES="Type predicate"]
  92. @desc[(CHAR? @i[object]) @yl[] @i[boolean]]
  93. Returns true if @i[object] is a character.
  94.   @begin[ProgramExample]
  95. (CHAR? #\X)  @ev[]  @r[true]
  96.   @end[ProgramExample]
  97. @EndDesc[CHAR?]
  98.  
  99. @info[NOTES="Type predicate"]
  100. @desc[(STRING? @i[object]) @yl[] @i[boolean]]
  101. Returns true if @i[object] is a string.
  102.   @begin[ProgramExample]
  103. (STRING? "Tapir.")  @ev[]  @r[true]
  104.   @end[ProgramExample]
  105. @EndDesc[STRING?]
  106.  
  107. @desc[(GRAPHIC? @i[character]) @yl[] @i[boolean]]
  108. Returns true if @i[character] is either the space character (@tc[#\SPACE]) or
  109. it corresponds to a printed graphic such as a letter, digit, or punctuation 
  110. mark.
  111.   @begin[ProgramExample]
  112. (GRAPHIC? #\X)        @ev[]  @r[true]
  113. (GRAPHIC? #\NEWLINE)  @ev[]  @r[false]
  114.   @end[ProgramExample]
  115. @EndDesc[GRAPHIC?]
  116.  
  117. @desc[(WHITESPACE? @i[character]) @yl[] @i[boolean]]
  118. Returns true if @i[character] is a whitespace character (blank, tab,
  119. newline, carriage return, line feed, or form feed).
  120. @index[Whitespace]
  121.   @begin[ProgramExample]
  122. (WHITESPACE? #\X)        @ev[]  @r[false]
  123. (WHITESPACE? #\NEWLINE)  @ev[]  @r[true]
  124.   @end[ProgramExample]
  125. @EndDesc[WHITESPACE?]
  126.  
  127. @desc[(ALPHABETIC? @i[character]) @yl[] @i[boolean]]
  128. Returns true if @i[character] is an alphabetic (upper or lower case)
  129. character.
  130.   @begin[ProgramExample]
  131. (ALPHABETIC? #\y)  @ev[]  @r[true]
  132. (ALPHABETIC? #\7)  @ev[]  @r[false]
  133.   @end[ProgramExample]
  134. @EndDesc[ALPHABETIC?]
  135.  
  136. @desc[(UPPERCASE? @i[character]) @yl[] @i[boolean]]
  137. Returns true if @i[character] is an upper-case letter.
  138.   @begin[ProgramExample]
  139. (UPPERCASE? #\y)      @ev[]  @r[false]
  140. (UPPERCASE? #\Y)      @ev[]  @r[true]
  141. (UPPERCASE? #\COMMA)  @ev[]  @r[false]
  142.   @end[ProgramExample]
  143. @EndDesc[UPPERCASE?]
  144.  
  145. @desc[(LOWERCASE? @i[character]) @yl[] @i[boolean]]
  146. Returns true if @i[character] is a lower-case letter.
  147.   @begin[ProgramExample]
  148. (LOWERCASE? #\y)      @ev[]  @r[true]
  149. (LOWERCASE? #\Y)      @ev[]  @r[false]
  150. (LOWERCASE? #\COMMA)  @ev[]  @r[false]
  151.   @end[ProgramExample]
  152. @EndDesc[LOWERCASE?]
  153.  
  154. @desc[(DIGIT? @i[character radix]) @yl[] @i[boolean]]
  155. Returns true if @i[character] is a digit with respect to the given
  156. @i[radix].
  157. @begin[ProgramExample]
  158. (DIGIT? #\5 10)  @ev[]  @r[true]
  159. (DIGIT? #\a 10)  @ev[]  @r[false]
  160. (DIGIT? #\a 16)  @ev[]  @r[true]
  161. @end[ProgramExample]
  162. @EndDesc[DIGIT?]
  163.  
  164. @section[Comparison]
  165.  
  166. @descN[
  167. F1="(CHAR= @i[char1 char2]) @yl[] @i[boolean]",  FN1="CHAR=",  NL1,
  168. F2="(CHAR< @i[char1 char2]) @yl[] @i[boolean]",  FN2="CHAR<",  NL2,
  169. F3="(CHAR> @i[char1 char2]) @yl[] @i[boolean]",  FN3="CHAR>",  NL3,
  170. F4="(CHARN= @i[char1 char2]) @yl[] @i[boolean]", FN4="CHARN=", NL4,
  171. F5="(CHAR>= @i[char1 char2]) @yl[] @i[boolean]", FN5="CHAR>=", NL5,
  172. F6="(CHAR<= @i[char1 char2]) @yl[] @i[boolean]", FN6="CHAR<=", NL6
  173. ]
  174. @dc{ Horrible explanation. }
  175. Six comparison predicates are defined for characters.
  176. @tc[CHAR=] and @tc[CHARN=] are defined for all characters.
  177. The others are defined only when the arguments are both
  178. upper-case letters, or both lower-case letters, or both digits.
  179. @EndDescN[]
  180.  
  181. @desc[(STRING-EQUAL? @i[string1 string2]) @yl[] @i[boolean]]
  182. Returns true if the two strings have the same length and characters.
  183. @EndDesc[STRING-EQUAL?]
  184.  
  185. @section[String constructors]
  186. @desc[(MAKE-STRING @i[length]) @yl[] @i[string]]
  187. Makes a string of null characters whose length is @i[length].
  188. @EndDesc[MAKE-STRING]
  189.  
  190. @desc[(STRING-APPEND . @i[strings]) @yl[] @i[string]]
  191. Returns a new string which is the concatenation of @i[strings].
  192.   @begin[ProgramExample]
  193. (STRING-APPEND "llama" " and " "alpaca")  @ev[]  "llama and alpaca"
  194.   @end[ProgramExample]
  195. @EndDesc[STRING-APPEND]
  196.  
  197. @desc[(COPY-STRING @i[string]) @yl[] @i[string]]
  198. Returns a new string, with new text,
  199. whose characters and length are the same
  200. as those of @i[string].
  201. @EndDesc[COPY-STRING]
  202.  
  203. @desc[(CHAR->STRING @i[character]) @yl[] @i[string]]
  204. Creates a string of length one whose single element is @i[character].
  205.   @begin[ProgramExample]
  206. (CHAR->STRING #\B)  @ev[]  "B"
  207.   @end[ProgramExample]
  208. @EndDesc[CHAR->STRING]
  209.  
  210. @desc[(LIST->STRING @i[list]) @yl[] @i[string]]
  211. Converts a list of characters to a string.
  212.   @begin[ProgramExample]
  213. (LIST->STRING '(#\Z #\e #\b #\u))  @ev[]  "Zebu"
  214.   @end[ProgramExample]
  215. @EndDesc[LIST->STRING]
  216.  
  217. @desc[(STRING->LIST @i[string]) @yl[] @i[list]]
  218. Converts a string to a list of characters.
  219.   @begin[ProgramExample]
  220. (STRING->LIST "Zebu")  @ev[]  (#\Z #\e #\b #\u)
  221.   @end[ProgramExample]
  222. @EndDesc[STRING->LIST]
  223.  
  224.  
  225. @section[String access]
  226.  
  227. @info[NOTES="Settable"]
  228. @desc[(STRING-LENGTH @i[string]) @yl[] @i[integer]]
  229. Returns @i[string]'s length.
  230. A string's length may be @tc[SET], but the new length must be less
  231. than or equal to the original length.
  232. @EndDesc[STRING-LENGTH]
  233.  
  234. @descN[
  235. F1="(STRING-EMPTY? @i[string]) @yl[] @i[boolean]", FN1="STRING-EMPTY?",
  236. ]
  237. Returns true if @i[string] is an empty string.
  238. @begin[ProgramExample]
  239. @tabclear
  240. (STRING-EMPTY? "")         @^@ev[]  @r[true]
  241. (STRING-EMPTY? "Bharal")@\@ev[]  @r[false]
  242. (STRING-EMPTY? @i[string])@\@ce[]  (=0? (STRING-LENGTH @i[string]))
  243. @tabclear
  244. @end[ProgramExample]
  245. @EndDescN[]
  246.  
  247. @AnEquivE[Tfn="STRING-ELT",Efn="GETCHAR"]
  248. @AnEquivE[Tfn="STRING-ELT",Efn="GETCHARN"]
  249. @info[NOTES="Settable"]
  250. @descN[
  251. F1="(STRING-ELT @i[string n]) @yl[] @i[character]", FN1="STRING-ELT",
  252. F2="(NTHCHAR @i[string n]) @yl[] @i[character]", FN2="NTHCHAR"
  253. ]
  254. Returns the @i[n]@+[th] character in @i[string] (zero-based).
  255. @begin[ProgramExample]
  256. (NTHCHAR "SAIGA" 2)  @ev[]  #\I
  257. @end[ProgramExample]
  258. @EndDescN[]
  259.  
  260. @info[NOTES="Settable"]
  261. @descN[
  262. F1="(STRING-HEAD @i[string]) @yl[] @i[character]", FN1="STRING-HEAD",
  263. F2="(CHAR @i[string]) @yl[] @i[character]", FN2="CHAR"
  264. ]
  265. Returns first character in @i[string].
  266. @EndDescN[]
  267.  
  268. @descN[
  269. F1="(STRING-TAIL @i[string]) @yl[] @i[string]", FN1="STRING-TAIL",
  270. F2="(CHDR @i[string]) @yl[] @i[string]", FN2="CHDR"
  271. ]
  272. Returns the @qu"tail" of @i[string].
  273. @begin[ProgramExample]
  274. (STRING-TAIL "Ibex.")  @ev[]  "bex."
  275. @end[ProgramExample]
  276. @EndDescN[]
  277.  
  278. @descN[
  279. F1="(STRING-NTHTAIL @i[string n]) @yl[] @i[string]",
  280. FN1="STRING-NTHTAIL",
  281. F2="(NTHCHDR @i[string n]) @yl[] @i[string]", FN2="NTHCHDR"
  282. ]
  283. Returns the @i[n]@+[th] tail of @i[string].
  284.   @begin[ProgramExample]
  285. (NTHCHDR "SAIGA" 2)  @ev[]  "IGA"
  286.   @end[ProgramExample]
  287. @EndDescN[]
  288.  
  289. @descN[
  290. F1="(SUBSTRING @i[string start count]) @yl[] @i[string]", FN1="SUBSTRING",
  291. ]
  292. Returns a substring of @i[string], beginning with the @i[start]@+[th] character,
  293. for a length of @i[count] characters.
  294. @begin[ProgramExample]
  295. (SUBSTRING "A small oryx" 2 5)  @ev[]  "small"
  296. @end[ProgramExample]
  297. @EndDescN[]
  298.  
  299. @AnEquivE[Tfn="STRING-SLICE",Efn="NSUBSTRING"]
  300. @desc[(STRING-SLICE @i[string start count]) @yl[] @i[string]]
  301. Returns a substring (slice) of @i[string], beginning with the @i[start]@+[th]
  302. character, for a length of @i[count] characters.
  303. @begin[ProgramExample]
  304. (STRING-SLICE "A small oryx" 2 5)  @ev[]  "small"
  305. @end[ProgramExample]
  306. Unlike @tc[SUBSTRING], the characters returned by
  307. @tc[STRING-SLICE] are shared with the original string;
  308. that is, any changes to characters
  309. in the original string which have been selected in the substring
  310. are reflected in the substring, and vice versa.
  311. @EndDesc[STRING-SLICE]
  312.  
  313.  
  314. @section[String manipulation]
  315.  
  316. @desc[(STRING-POSQ @i[character string]) @yl[] @i[integer] @r[or] @i[false]]
  317. Returns the index of the first occurrence of
  318. @i[character] in @i[string], if it is there;
  319. otherwise returns false.
  320. @begin[ProgramExample]
  321. (STRING-POSQ #\i "oribi")  @ev[]  2
  322. (STRING-POSQ #\s "oribi")  @ev[]  @r[false]
  323. @end[ProgramExample]
  324. @EndDesc[STRING-POSQ]
  325.  
  326. @desc[(STRING-REPLACE @i[destination source count]) @yl[] @i[string]]
  327. Copies @i[count] characters from the @i[source] string to the
  328. @i[destination] string, destructively, and return the modified
  329. @i[destination].
  330. @begin[ProgramExample]
  331. (DEFINE S (COPY-STRING "The bison"))
  332. (STRING-REPLACE S "Any how" 3)  @ev[]  "Any bison"
  333. @end[ProgramExample]
  334. @dc[This may be renamed to be @tc[STRING-REPLACE!].]
  335. @EndDesc[STRING-REPLACE]
  336.  
  337. @desc[(MAP-STRING @i[procedure string]) @yl[] @i[string]]
  338. Calls @i[procedure] on each character in @i[string], collecting
  339. the successive return values which should be characters
  340. in a new string.
  341. @begin[ProgramExample]
  342. (MAP-STRING CHAR-UPCASE "A grisbok")  @ev[]  "A GRISBOK"
  343. @end[ProgramExample]
  344. @EndDesc[MAP-STRING]
  345.  
  346. @desc[(MAP-STRING! @i[procedure string]) @yl[] @i[string]]
  347. Calls @i[procedure] on each character in @i[string], storing the results
  348. which should be characters back into @i[string].
  349. @EndDesc[MAP-STRING!]
  350.  
  351. @desc[(WALK-STRING @i[procedure string]) @yl[] @i[undefined]]
  352. Calls @i[procedure] on each character in @i[string].
  353. @EndDesc[WALK-STRING]
  354.  
  355.  
  356. @section[String header manipulation]
  357. @Label(string header section)
  358.  
  359. A @iixs[string header] is a structure of fixed size which contains a
  360. pointer into a @iixs[string text], and a length.  A string text is a
  361. vector of characters themselves.  The string text is not itself a directly
  362. accessible object, but can only be manipulated
  363. via a string header.  Several string headers may point into the same text.
  364. The term @i[string] is used to refer to a header and text considered
  365. as a whole.
  366.  
  367. @desc[(CHOPY @i[string]) @yl[] @i[string]]
  368. Makes a new string header pointing to the same string text,
  369. and with the same length, as the header for @i[string].
  370. @EndDesc[CHOPY]
  371.  
  372. @desc[(CHOPY! @i[destination source]) @yl[] @i[string]]
  373. Copies the header for the @i[source] string into the header
  374. for the @i[destination] string, which is returned.
  375. @EndDesc[CHOPY!]
  376.  
  377. @descN[
  378. F1="(STRING-TAIL! @i[string]) @yl[] @i[string]", FN1="STRING-TAIL!",
  379. F2="(CHDR! @i[string]) @yl[] @i[string]", FN2="CHDR!"
  380. ]
  381. Destructively modifies @i[string]'s header to point to the next
  382. character in its text, and decrements its length.
  383. @begin[ProgramExample]
  384. (LET ((S (COPY-STRING "String.")))
  385.   (CHDR! S)
  386.   S)
  387.         @ev[]
  388. "tring."
  389. @end[ProgramExample]
  390. @EndDescN[]
  391.  
  392. @descN[
  393. F1="(STRING-NTHTAIL! @i[string n]) @yl[] @i[string]", FN1="STRING-NTHTAIL!",
  394. F2="(NTHCHDR! @i[string] n) @yl[] @i[string]", FN2="NTHCHDR!"
  395. ]
  396. Destructive version of @tc[STRING-NTHTAIL].
  397. @EndDescN[]
  398.  
  399.  
  400. @section[Case conversion]
  401.  
  402. @desc[(CHAR-UPCASE @i[character]) @yl[] @i[character]]
  403. If @i[character] is a lower-case character, returns the corresponding
  404. upper-case character.  Otherwise @i[character], which must be a character,
  405. is returned.
  406. @EndDesc[CHAR-UPCASE]
  407.  
  408. @desc[(CHAR-DOWNCASE @i[character]) @yl[] @i[character]]
  409. If @i[character] is an upper-case character, returns the corresponding
  410. lower-case character.  Otherwise @i[character], which must be a character,
  411. is returned.
  412. @EndDesc[CHAR-DOWNCASE]
  413.  
  414. @desc[(STRING-UPCASE @i[string]) @yl[] @i[string]]
  415. Returns a copy of @i[string] with all lower-case characters converted to
  416. upper case.
  417. @begin[ProgramExample]
  418. (STRING-UPCASE @i[string])  @ce[]  (MAP-STRING CHAR-UPCASE @i[string])
  419. @end[ProgramExample]
  420. @EndDesc[STRING-UPCASE]
  421.  
  422. @desc[(STRING-DOWNCASE @i[string]) @yl[] @i[string]]
  423. Returns a copy of @i[string] with all upper-case characters converted to
  424. lower case.
  425. @begin[ProgramExample]
  426. (STRING-DOWNCASE @i[string])  @ce[]  (MAP-STRING CHAR-DOWNCASE @i[string])
  427. @end[ProgramExample]
  428. @EndDesc[STRING-DOWNCASE]
  429.  
  430. @desc[(STRING-UPCASE! @i[string]) @yl[] @i[string]]
  431. Destructive version of @tc[STRING-UPCASE].
  432. @begin[ProgramExample]
  433. (STRING-UPCASE! @i[string])  @ce[]  (MAP-STRING! CHAR-UPCASE @i[string])
  434. @end[ProgramExample]
  435. @EndDesc[STRING-UPCASE!]
  436.  
  437. @desc[(STRING-DOWNCASE! @i[string]) @yl[] @i[string]]
  438. Destructive version of @tc[STRING-DOWNCASE].
  439. @begin[ProgramExample]
  440. (STRING-DOWNCASE! @i[string])  @ce[]  (MAP-STRING! CHAR-DOWNCASE @i[string])
  441. @end[ProgramExample]
  442. @EndDesc[STRING-DOWNCASE!]
  443.  
  444.  
  445. @section[Digit conversion]
  446.  
  447. @desc[(CHAR->DIGIT @i[character radix]) @yl[] @i[integer]]
  448. Returns the @iix[weight] of the character when treated as a digit.
  449. @i[Character] must be a digit in the given @i[radix].
  450. @begin[ProgramExample]
  451. (CHAR->DIGIT #\A 16)  @ev[]  10
  452. @end[ProgramExample]
  453. @EndDesc[CHAR->DIGIT]
  454.  
  455. @desc[(DIGIT->CHAR @i[integer radix]) @yl[] @i[character]]
  456. Given a non-negative @i[integer] less than @i[radix],
  457. returns a character (a digit) whose weight is the @i[integer].
  458. @begin[ProgramExample]
  459. (DIGIT->CHAR 10 16)  @ev[]  #\A
  460. @end[ProgramExample]
  461. @EndDesc[DIGIT->CHAR]
  462.  
  463. @desc[(DIGIT @i[character radix]) @yl[] @i[integer] @r[or] @i[false]]
  464. If @i[character] is a digit, returns its weight;
  465. otherwise returns false.
  466. @begin[ProgramExample]
  467. (DIGIT #\5 10)  @ev[]  5
  468. @end[ProgramExample]
  469. @EndDesc[DIGIT]
  470.  
  471. @section[ASCII conversion]
  472.  
  473. @dc{Talk about coercion to and from integers, and the arbitrariness of the ASCII
  474. character set.  Refer to Appendix @ref[ascii appendix].}
  475.  
  476. @AnEquivE[Tfn="CHAR->ASCII",Efn="CHAR-CODE"]
  477. @desc[(CHAR->ASCII @i[character]) @yl[] @i[integer]]
  478. Given a character, returns its ASCII representation as an integer.
  479. @EndDesc[CHAR->ASCII]
  480.  
  481. @AnEquivE[Tfn="ASCII->CHAR",Efn="CODE-CHAR"]
  482. @desc[(ASCII->CHAR @i[integer]) @yl[] @i[character]]
  483. Given an integer which is the ASCII code for some character,
  484. returns the character.
  485. @EndDesc[ASCII->CHAR]
  486.  
  487. @desc[*NUMBER-OF-CHAR-CODES* @yl[] @i[integer]]
  488.  
  489. The value of @tc[*NUMBER-OF-CHAR-CODES*] is a number that is
  490. 1 larger than the largest value that will ever be returned by
  491. @tc[CHAR->ASCII].  This may be used to make tables which are
  492. to be indexed by ASCII codes.
  493.  
  494. @begin[ProgramExample]
  495. (DEFINE *TABLE* (MAKE-VECTOR *NUMBER-OF-CHAR-CODES*))  @ev[]  @i[vector]
  496. (VSET *TABLE* (CHAR->ASCII #\F) 'COW)                  @ev[]  COW
  497. (VREF *TABLE* (CHAR->ASCII #\F))                       @ev[]  COW
  498. @end[ProgramExample]
  499.  
  500. @EndDesc[*NUMBER-OF-CHAR-CODES*]
  501.  
  502.  
  503. @section[Symbols]
  504.  
  505. Symbols are similar to strings, but are instantiated uniquely; only one
  506. symbol with a given print name exists.  Symbols are used to identify
  507. variables, among other things.  The fact that they have a convenient
  508. external representation makes them useful for many purposes.
  509.  
  510. Symbols may be coerced to strings and vice versa.
  511. If two strings are equal to each other (e.g. according
  512. to @tc[STRING-EQUAL?]), then they will both convert to the same symbol.
  513.   @begin[ProgramExample]
  514. (EQ? (STRING->SYMBOL @i[string1]) (STRING->SYMBOL @i[string2]))
  515.   @end[ProgramExample]
  516. if and only if
  517.   @begin[ProgramExample]
  518. (STRING-EQUAL? @i[string1] @i[string2])
  519.   @end[ProgramExample]
  520.  
  521. See also sections @ref[SYMBOL?] and @ref[reader].
  522.  
  523. @desc[(STRING->SYMBOL @i[string]) @yl[] @i[symbol]]
  524. Returns the symbol whose print name is equal to @i[string].
  525.   @begin[ProgramExample]
  526. (STRING->SYMBOL "COW")    @ev[]  COW
  527. (STRING->SYMBOL "123")    @ev[]  \123
  528. (STRING->SYMBOL "bison")  @ev[]  \b\i\s\o\n
  529. (STRING->SYMBOL "")       @ev[]  #[Symbol ""]
  530.   @end[ProgramExample]
  531. Note that it is @tc[READ-OBJECT] (page @pageref[READ-OBJECT]), not
  532. @tc[STRING->SYMBOL], which coerces alphabetic characters to upper case.
  533. @EndDesc[STRING->SYMBOL]
  534.  
  535. @desc[(SYMBOL->STRING @i[symbol]) @yl[] @i[string]]
  536. Returns a string for which @tc[STRING->SYMBOL] will return @i[symbol].
  537.   @begin[ProgramExample]
  538. (SYMBOL->STRING 'COW)  @ev[]  "COW"
  539.   @end[ProgramExample]
  540. @EndDesc[SYMBOL->STRING]
  541.